<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use think\db\exception\PDOException;
use think\exception\ValidateException;
use think\facade\Db;

/**
 * 充值订单
 *
 */
class RechargeOrder extends Backend
{
    /**
     * RechargeOrder模型对象
     * @var \app\admin\model\RechargeOrder
     */
    protected $model = null;

    protected $quickSearchField = ['id'];

    protected $defaultSortField = 'id,desc';

    protected $withJoinTable = ['user'];

    protected $preExcludeFields = ['createtime'];

    public function initialize()
    {
        parent::initialize();
        $this->model = new \app\admin\model\RechargeOrder;
    }

    public function edit()
    {
        $id = $this->request->param($this->model->getPk());
        $row = $this->model->find($id);
        if (!$row) {
            $this->error(__('Record not found'));
        }

        $dataLimitAdminIds = $this->getDataLimitAdminIds();
        if ($dataLimitAdminIds && !in_array($row[$this->dataLimitField], $dataLimitAdminIds)) {
            $this->error(__('You have no permission'));
        }

        if ($this->request->isPost()) {
            $this->success(__('Update successful'));
        }

        $this->success('', [
            'row' => $row
        ]);
    }

}